package br.uvv.sao.converter;

import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;

import br.uvv.sao.enums.SituDisciplina;

public class SituDisciplinaConverter implements Converter {

	@Override
	public Object getAsObject(FacesContext arg0, UIComponent arg1, String arg2) {
		if(arg2 != null){
			if(arg2.toString().equals("Ativa")){
				return SituDisciplina.Ativa;
			}else{
				if(arg2.toString().equals("Inativa")){
					return SituDisciplina.Inativa;
				}
			}
		}
		return null;
	}

	@Override
	public String getAsString(FacesContext arg0, UIComponent arg1, Object arg2) {
		if(arg2 != null){
			if(arg2.toString().equals("Ativa")){
				return "Ativa";
			}else{
				if(arg2.toString().equals("Inativa")){
					return "Inativa";
				}
			}
		}
		return "Selecione...";
	}

}
